/* eslint-disable @typescript-eslint/no-var-requires */
const express = require('express')
const { createProxyMiddleware } = require('http-proxy-middleware')

const app = express()
app.use(express.static('./dist'))

// set proxy
// '/boss': {
//   // target: 'http://edufront.lagou.com',
//   target: 'http://eduboss.lagou.com',
//   changeOrigin: true // 把请求头中的 host 配置为 target
// },
// '/front': {
//   target: 'http://edufront.lagou.com',
//   changeOrigin: true
// }

app.use('/boss', createProxyMiddleware(
  { target: 'http://eduboss.lagou.com', changeOrigin: true }
))
app.use('/front', createProxyMiddleware(
  { target: 'http://edufront.lagou.com', changeOrigin: true }
))

app.get('/', (req, res) => {
  res.send('hi')
})

const port = 3000
app.listen(port, () => {
  console.log('listen', port)
})
